
package com.avocado.base.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import lombok.Data;




/**
 *
 * @author wenfeng.xu
 *2011-4-24下午10:14:35
 */
@Entity
@Table(name="AVO_RESOURCES_ROLE")
@Data
public class ResourcesRole implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1787066029325828326L;
	
	@EmbeddedId
	@AttributeOverrides( {
	@AttributeOverride(name="resourcesId", column=@Column(name="RESOURCES_ID", nullable=false) ), 
	@AttributeOverride(name="roleId", column=@Column(name="ROLE_ID", nullable=false) ) } )
	private ResourcesRoleId id;
		
	@ManyToOne
	@JoinColumn(name="ROLE_ID", nullable=false, insertable=false, updatable=false)
	private Role role;
		
	@ManyToOne
	@JoinColumn(name="RESOURCES_ID", nullable=false, insertable=false, updatable=false)
	private Resources resources;
	
	@Temporal(TemporalType.TIMESTAMP)@Column(nullable=false,name="CREATE_TIME")
	private Date createTime=new Date();

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		ResourcesRole that = (ResourcesRole) o;
		return Objects.equals(id, that.id);
	}

	@Override
	public int hashCode() {
		return Objects.hash(id);
	}
}
